<?php
    header('Access-Control-Allow-Origin: *');
    header('Content-Type:application/json;charset=utf-8');
    // header('Content-Type:text/html;charset=utf-8');
    $con = mysqli_connect("localhost", "root", "root", "mydb");
    $uid = $_GET['uid'];
    $status = $_GET['status'];
    if($status == 'student'){
        $sql = "SELECT stu_name FROM stu_info WHERE stu_id = '$uid';";
        $res = mysqli_query($con,$sql);
        while($row = mysqli_fetch_array($res)){
            $item = array(
                'uname' => $row['stu_name'],
            );
        }
    }else{
        $sql = "SELECT t_name FROM tch_info WHERE t_id = '$uid';";
        $res = mysqli_query($con,$sql);
        while($row = mysqli_fetch_array($res)){
            $item = array(
                'uname' => $row['t_name'],
            );
        }
    }
    echo json_encode($item);
    mysqli_close($con);
?>